import {makeObservable,observable,action,computed} from 'mobx'

type userInfotype = {
    username:string,
    nickname:string
}

class UserInfoMobx {
    username = ""
    nickname = ""
    constructor(){
        makeObservable({
            username:observable,
            nickname:observable,
            setUserInfo:action,
            resetUserInfo:action,
            getUserInfo:computed
        })
        this.username = ''
        this.nickname = ''
    }

    get getUserInfo(){
        return {
            username:this.username,
            nickname:this.nickname
        }
    }

    setUserInfo(value:userInfotype){
        this.username = value.username
        this.nickname = value.nickname
    }

    resetUserInfo(){
        this.username = ''
        this.nickname = ''
    }

}


export default UserInfoMobx